package JDKtest.java_lang_test.List;

import JDKtest.java_lang_test.List.ListNode;

import java.util.List;

public class ListCreate {
    public static void main(String[] args) {
//        ListNode node1= new ListNode(1);
//        ListNode node2= new ListNode(2);
//        ListNode node3= new ListNode(3);
//
//        // connect nodes
//
//        node1.next=node2;
//        node2.next=node3;

        ListNode node1= new ListNode(1,new ListNode(2,new ListNode(3)));
        printList(node1);

    }

    // 链表打印
    public static void printList(ListNode head) {
        ListNode current = head;
        while (current != null) {
            System.out.print(current.val);
            if(current.next != null){
                System.out.print(" -> ");
            }
            current = current.next;
        }
        System.out.println();
    }
}
